package com.harvey.coding.lambda.stream;

import com.harvey.coding.lambda.cart.CartService;
import com.harvey.coding.lambda.cart.Sku;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

public class StreamCollect {
    public void toList(){
        CartService.getCartSkuList().stream().collect(Collectors.toList());
    }

    public void groupBy() {
        Map<Object, List<Sku>> groupByResult = CartService.getCartSkuList().stream()
                .collect(Collectors.groupingBy(s -> s.getSkuCategory()));
    }

    public void partition() {
        Map<Boolean, List<Sku>> p = CartService.getCartSkuList().stream()
                .collect(Collectors.partitioningBy(s -> s.getTotalNum() > 5));
    }
}
